package org.mindrive.system.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mindrive.system.collection.expenses.ApprovalEntity;

import java.util.List;

/**
 * (Approval)表数据库访问层
 *
 * @author maweihong
 * @since 2023-10-30 14:22:27
 */
public interface ApprovalMapper extends BaseMapper<ApprovalEntity> {

    @Select("SELECT * FROM APPROVAL WHERE FINANCE_RESULT = '通过' AND YEAR(FORMS_TIME) = #{year} AND MONTH(FORMS_TIME) = #{month}")
    List<ApprovalEntity> searchApprovalByTime( @Param("year") int year , @Param("month") int month);

    @Select("SELECT * FROM APPROVAL AS AP JOIN ROLE AS RO ON AP.REPORTING_ROLE_ID = RO.ID WHERE FINANCE_RESULT = '通过' AND YEAR(AP.FORMS_TIME) = #{year} AND MONTH(AP.FORMS_TIME) = #{month} AND RO.NAME like CONCAT('%',#{roleName},'%') ")
    List<ApprovalEntity> searchApprovalByTimeAndRole( @Param("year") int year , @Param("month") int month , @Param("roleName") String roleName);
}
